README for Gandhi and Sumner (2019) Consolidation of Power in Non-Democracies.

## Software:
Estimates and all figures were done using R (3.5.3).
(Previous versions ran in older versions of R without difficulties.) 
All tables done in STATA.

## Computer Specification (for measurement model):
Run time, etc based on the following
computer specifications:
Intel(R) Xeon (R) CPU E5-2620 v4 @ 2.10GHz 2.10 GHz (2 processors)
64.0 GB Installed RAM
Windows 10

## Files:
R file (for estimates and figures) : gandhi-sumner-replication-code.R
Data  (to run estimation model): gandhi-sumner-replication.csv
Data (for our estimates for making figures): 
(1) gandhi-sumner-estimates.csv
(2) item-chars-1-4-2019.csv
STATA file (for tables): Tables.do 
Data (for tables): Tables.dta
Additional data (not for replication):
using-estimates-code.R 
This code is discussed in the text and provides some insight for how to use our estimates in analyses.

## Required R Packages:
reshape2 (v. 1.4.3)
R2jags (v. 0.5.7)
stringr (v. 1.4.0)

## Other software for estimates:
For the latent variable estimation (but not the rest of it), you need to install JAGS.
I used JAGS 4.2.0.
You can install JAGS here: http://mcmc-jags.sourceforge.net/

## Run time:
21.85 hours (for latent variable estimation, with 50,000 iterations)
4.56 seconds (figures)

## Codebook for Tables.dta
See document "Codebook for Tables.dta"

## Codebook for gandhi-sumner-replication-data.csv
leaderspell - the leader's name and country along with which tenure number they are in the data. For instance,
              the first leader for a country in our data is 1, the second is 2, the third is 3, etc.
	      (This allows us to separate leaders who had nonconsecutive spells in power.)
year - year
firstyear - 1 if it's the first year of a leader's tenure in office, 0 otherwise
country - Country name
dpurgenew - Domestic purges. Banks' (2011) indicator of "any systematic elimination by jailing or execution of political opposition
	within the ranks of the regime or the opposite", coded 1 the year a domestic purge occurs and for every year afterwards
	within a leader's tenure.
mpurgenew - Military purges. Sudduth's (2017) dichotomous indicator of whether a dictator �replaces, dismisses, or demotes rival 
	elites who have legitimate access to coercive forces in a specific year� (p.1782). Takes on a value of 1 in the year a 
	military purge occurs and for every year afterwards within a leader�s tenure.
cabchangenew - Banks� (2011) measure of Cabinet change, which we have coded to take the value of 1 in the year �a new 
	premier is named and/or 50 percent of the cabinet posts are assumed by new ministers.� 
aclpautocracy - Dictator before transition takes the value of 1 for all country-years in which a leader rules as a dictator before becoming a democrat. 
nocollective - No formal collective collective takes the value of 1 when the executive is not formally collective, 0 otherwise.
svolikrecode - Recode of Svolik (2012) coding of military involvement in authoritarian rule. Takes the value of 1 if the military as an 
	institution indirectly or directly constrains the executive and 0 otherwise.
noregimeparty - No regime party is coded 1 if the leader rules without the support of an official governing party and 0 otherwise.
foundedwhileinpower - Founded while in power is coded 1 beginning in the year the ruler founds the regime party and every year afterwards, 0 otherwise.
multipleparties - Multiple parties is a dichotomous variable that takes on a value of 1 if a leader has been associated with more than one party, and 
	zero otherwise. 
noposition - No position takes the value of 1 if the ruler was the de facto chief executive without an official title, 0 otherwise.
twoposition - Two positions is a dichotomous indicator that takes the value of 1 for every year that a leader occupies two official 
	political positions and 0 otherwise.
threeposormore - Three or more positions is a dichotomous indicator that takes the value of 1 for every year that a leader occupies at 
	least three official positions, 0 otherwise.
faminpower - Family in office, which takes the value of 1 if any of the leader�s immediate family occupies political office and 0 otherwise.

## Codebook for gandhi-sumner-estimates.csv 
countryleader year - The leader, country, and year of the observation.
year - the year of the observation
leaderspell - the leader's name and country along with which tenure number they are in the data. For instance,
              the first leader for a country in our data is 1, the second is 2, the third is 3, etc.
	      (This allows us to separate leaders who had nonconsecutive spells in power.)
firstyear - 1 if it's the first year of the particular leaderspell, 0 otherwise
country - The name of the country.
xhatmean - The mean of the posterior distribution of the latent variable.
xhatmedian - The median of the posterior distribution of the latent variable.
xhatsd - The standard deviation of the posterior distribution of the latent variable.
xhat025 - The 2.5 percentile of the posterior distribution of the latent variable.
xhat975 - The 97.5 percentile of the posterior distribution of the latent variable.
countryleaderspan - The leader name, country, and period of time that leader was in power for that spell.